package com.lyt.springboot.designPattern.observerPattern;

// 具体观察者类：士兵
class Soldier implements Observer {
    private String name;

    public Soldier(String name) {
        this.name = name;
    }

    @Override
    public void update(String command) {
        System.out.println(name + " received command: " + command);
        // 执行命令（这里只是打印出来，实际中可以是具体的行动）
        executeCommand(command);
    }

    private void executeCommand(String command) {
        // 根据命令执行相应的操作
        System.out.println(name + " is executing command: " + command);
    }
}